package com.system.manager.modules.risk.controller;


import com.system.manager.common.annotation.CurrSubject;
import com.system.manager.common.annotation.PreAuthorize;
import com.system.manager.common.entity.Result;
import com.system.manager.modules.authorized.entity.Subject;
import com.system.manager.modules.authorized.enums.SubjectType;
import com.system.manager.modules.risk.entity.Risk;
import com.system.manager.modules.risk.entity.RiskType;
import com.system.manager.modules.risk.entity.TbTask;
import com.system.manager.modules.risk.service.ITbTaskService;
import com.system.manager.modules.risk.vo.TaskDate;
import com.system.manager.modules.risk.vo.UserDate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yxp
 * @since 2021-11-09
 */
@Slf4j
@Api(tags = "教育任务")
@RestController
@RequestMapping("/risk/tb-task/")
public class TbTaskController {


    @Autowired
    private ITbTaskService iTbTaskService;

    @ApiOperation("获取所有的考试信息")
    @PreAuthorize({SubjectType.SYSTEM_ADMIN,SubjectType.RISK_ADMIN})
    @GetMapping("findList")
    public Result riskTypeList(@CurrSubject Subject subject) {
        try {
            // 获取所有的风险类型
            UserDate<TaskDate> allTask = iTbTaskService.findAll(subject);

            return Result.ok(allTask.getData(),allTask.getCount());

        } catch (Exception e) {
            e.printStackTrace();
            // 查询数据库出现异常
            return Result.error();
        }
    }
}
